//
//  BatchDeptTreePopCell.swift
//  SBSafetyApp
//
//  Created by Lina on 2022/12/16.
//

import Foundation
import UIKit

class BatchDeptTreePopCell: BSDeptTreePopCell {
    func reload(withModal node: Node, curs: [String?]) {
        super.reload(withModal: node)
        
        var iF = false
        curs.forEach { item in
            if item == String(node.id) {
                iF = true
            }
        }
        
        if curs.count > 0 && iF {
            iconIV.image = UIImage(systemName: "checkmark.square.fill")
            iconIV.tintColor = .primary
        } else {
            iconIV.image = UIImage(systemName: "square")
            iconIV.tintColor = .hex("#EDEDED")
        }
        
        if !node.isLeaf {
            iconIV.image = nil
            iconIV.snp.updateConstraints { make in
                make.width.equalTo(0)
            }
        } else {
            iconIV.snp.updateConstraints { make in
                make.width.equalTo(25)
            }
        }
    }
}
